<?php
/**
 * Created by PhpStorm.
 * User: Lenovo PC
 * Date: 2016/7/21
 * Time: 14:17
 */

namespace Home\Model;
use \Think\Model;


class UsersModel extends Model
{
    protected $_validate = array(
        array('username', 'require', '用户名必须填写！', 1),
        array('username', '', '账号已经存在', 0, 'unique', self::MODEL_INSERT),
        array('username',array('administrator','admin'),'用户名不能是 administrator',1,'notin'),
        array('pass', 'require', '密码必须填写！', 1),
        array('pass1','pass','两次密码不一致',0,'confirm',1),//插入验证
        array('realname', 'require', '真实姓名必须填写'),
        array('email', 'require', '邮箱必须填写！', 1),
    );
    //添加自动填充规则
    protected $_auto = array(
        //为think_users表的createtime字段生成当前的日期
        array('createtime','date("Y-m-d")',self::MODEL_INSERT, 'function'),
        //为think_users表的pass字段进行md5加密
        array('pass','md5', self::MODEL_INSERT, 'function'),
    );
}